package cn.zb.mapper;

import cn.zb.entity.auth.SysUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author lewin
* @description 针对表【sys_user】的数据库操作Mapper
* @createDate 2024-11-11 10:35:30
* @Entity cn.zb.entity.auth.SysUser
*/
public interface SysUserMapper extends BaseMapper<SysUser> {
    /**
     * 根据用户名查询对象  登录时需要
     */
    @Select("select * from sys_user where user_name=#{username}")
    SysUser getByUsername(String username);
    /**
     * 根据用户名查询角色  授权时需要
     */
    @Select("select role_name from sys_role where role_id in (SELECT role_id from sys_user_role WHERE user_id in (select user_id FROM sys_user where user_name = #{yhm}))")
    List<String> getRoles(String username);
    /**
     * 根据用户名查询权限  授权时需要
     */
    @Select("select name from sys_permission where id in (select perid from sys_role_permission where roleid in (SELECT role_id from sys_user_role WHERE user_id in (select user_id FROM sys_user where user_name = #{yhm})))")
    List<String> getPerms(String username);
}




